package com.xiangyu.ai.controller;

import com.xiangyu.ai.domain.MemoryCacheDTO;
import com.xiangyu.ai.service.AiAssistant;
import com.xiangyu.ai.service.FunctionAssistant;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zxb
 * @version 1.0
 * @date 2025-04-28 11:28
 */
@RestController
@RequestMapping("/ai")
public class AIController {

    @Resource
    private AiAssistant aiAssistant;
    @Resource
    private FunctionAssistant functionAssistant;

    /**
     * 记忆缓存
     *
     * @param memoryCacheDTO
     */
    @PostMapping("/memoryCache")
    public String memoryCache(@RequestBody MemoryCacheDTO memoryCacheDTO) {
        String chat = aiAssistant.chat(memoryCacheDTO.getMemoryId(), memoryCacheDTO.getMsg());
        return chat;
    }

    @PostMapping("/test")
    public String test(String msg){
        String s = functionAssistant.chat(msg);
        return s;
    }
}
